package com.company.OfferGuide;

public class 把数字翻译成字符串 {

    public static void main(String[] args) {
        System.out.println(translateNum(18822));
    }

    public static int translateNum(int num){
        if (num == 0) return 1;
        String s = num+"";
        int[] dp = new int[s.length()];
        dp[0] = 1;
        for (int i = 1; i < dp.length; i++) {
            String substring = s.substring(i - 1, i + 1);
            int data = Integer.parseInt(substring);
            if (data > 25 || substring.startsWith("0")) {
                dp[i] = dp[i - 1] ;
            } else {
                if (i - 2 >= 0) {
                    dp[i] = dp[i - 1] + dp[i - 2];
                } else {
                    dp[i] = dp[ i - 1] + 1;
                }

            }
        }

        return dp[s.length() - 1];
    }

}
